import { ConfigComponent } from "../../../Core/Module/Config/ConfigComponent";
import { Root } from "../../../Core/Module/Entity/Root";
import { EventSystem } from "../../../Core/Module/EventSystem/EventSystem";
import { EventStruct } from "../../../Core/Module/EventSystem/IEvent";
import { NetServices } from "../../../Core/Module/Network/NetServices";
import { Game } from "../../../Core/Singleton/Game";

export module EntryEventType {

    export class EntryEvent1 extends EventStruct {

    }

    export class EntryEvent2 extends EventStruct {

    }

    export class EntryEvent3 extends EventStruct {

    }

}

export class Entry {

    public static Init() {

    }

    public static Start() {
        this.StartAsync().then();
    }

    private static async StartAsync() {
        Game.AddSingleton<NetServices>(NetServices);
        Game.AddSingleton<Root>(Root);
        await Game.AddSingleton<ConfigComponent>(ConfigComponent).LoadAsync();

        await EventSystem.Instance.PublishAsync(Root.Instance.Scene, EntryEventType.EntryEvent1);
        await EventSystem.Instance.PublishAsync(Root.Instance.Scene, EntryEventType.EntryEvent2);
        await EventSystem.Instance.PublishAsync(Root.Instance.Scene, EntryEventType.EntryEvent3);
    }

}